<?php

namespace app\apiadmin\model\behavior;

use app\apiadmin\model\mongoModel;

class LiveUserMongo extends mongoModel
{

    protected $collection = 'live_user_';

    protected $pk = '_id';

    public function __construct($id) {
        $this->collection = $this->collection.$id;
        parent::__construct();
    }

    public static function user_list($liveId,$where=['online_status'=>'1'])
    {
        $model = new static($liveId);
        return $model->query($where)->options([ 'sort' => ['_id' => 1]])->select();
    }
    public static function user_count($liveId){
        $model = new static($liveId);
        return $model->count();
    }

    public static function user_sum($liveId,$fieldName){
        $model = new static($liveId);
        return $model->sum($fieldName);
    }
    public static function list_array($liveId){
        $model = new static($liveId);
        return $model->select();
    }
}